// Address Book Implementation
// Person info: name + age + gender + phone + address
// 1. Store info for 100 people
// 2. Add, delete, modify, search
// 3. Sort
// 4. Show contacts
#include "contact.h"

enum Function
{
	Exit = 0,
	Add = 1,
	Del = 2,
	Modify = 3,
	Search = 4,
	Sort = 5,
	Show = 6
};

void menu() {
	printf("xxxxxxxxxxxx   1.Add       2.Del     xxxxxxxxxxx\n");
	printf("xxxxxxxxxxxx   3.Modify    4.Search  xxxxxxxxxxx\n");
	printf("xxxxxxxxxxxx   5.Sort      6.Show    xxxxxxxxxxx\n");
	printf("xxxxxxxxxxxx   0.exit                xxxxxxxxxxx\n");
}

int main() {
	int input = 0;

	Contact con;//通讯录
	//初始化通讯录
	InitContact(&con);


	do {
		menu();
		printf("请选择->\n");
		scanf_s("%d", &input);
		switch (input) {
		case Add:
			AddContact(&con);
			break;
		case Del:
			DelContact(&con);
			break;
		case Search:
			SearchContact(&con);
			break;
		case Modify:
			ModifyContact(&con);
			break;
		case Sort:
			SortContact(&con);
			break;
		case Show:
			ShowContact(&con);
			break;
		case Exit:
			SaveContact(&con);
			DestroyContact(&con);
			printf("已退出通讯录\n");
			break;
		default:
			printf("输入错误，请重新输入\n");
			break;
		}
	} while (input);
	return 0;
}